package com.ice.work.moment.user.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.honeybee.cloud.framework.common.page.Page;
import com.honeybee.cloud.framework.common.response.ResponseEntity;
import com.honeybee.cloud.framework.mybatis.page.PageMapper;
import com.honeybee.cloud.framework.oauth.controller.BaseController;
import com.ice.work.moment.facade.user.controller.resource.IResourceController;
import com.ice.work.moment.facade.user.dto.ResourceDTO;
import com.ice.work.moment.facade.user.mapper.ResourceConvertMapper;
import com.ice.work.moment.facade.user.model.Resource;
import com.ice.work.moment.facade.user.request.PageResourceRequest;
import com.ice.work.moment.facade.user.vo.ResourceVO;
import com.ice.work.moment.user.service.resource.IResourceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 用户
 * @Author DELL
 * @Create 2019-02-11
 * @Since 1.0.0
 */
@RestController
@Slf4j
public class ResourceController extends BaseController implements IResourceController {

    @Autowired
    private IResourceService resourceService;


    @Override
    public ResponseEntity<Page<ResourceVO>> pageResource(PageResourceRequest request, Long page, Long size) {
        IPage<Resource> iPage = PageMapper.INSTANCE.pageInfo(page,size);
        Page<ResourceDTO> resourceDTOPage = resourceService.page(iPage, request);
        Page<ResourceVO> voPage = ResourceConvertMapper.INSTANCE.toVO(resourceDTOPage);
        return ResponseEntity.ok(voPage);
    }
}
